<template>
  <BasicLayout/>
</template>

<script setup>
import BasicLayout from "@/layouts/BasicLayout";
// import user from "@/store/user";
import {useStore} from "vuex";
import {getInfo} from "@/api/user";

  let store = useStore();
  // 校验当前是否在登录状态
  // 每次刷新页面/切换页面时调用获取当前登录用户信息，并把用户信息存放到全局变量store的user.js中
  const jwt_token = localStorage.getItem('jwt_token')
  if (jwt_token) {
    store.commit("setToken", jwt_token);
    // 获取用户信息请求
    getInfo().then(res => {
      if (res.code === 20000) {
        // 存放用户信息
        store.commit('setUser', {
          ...res.data,
          is_login: true
        });
        // router.push({ name: "home" })
        store.commit("setPullingInfo", false);
      } else {
        store.commit("setPullingInfo", false);
      }
    }).catch(() => {
      store.commit("setPullingInfo", false);
    });
  } else {
    store.commit("setPullingInfo", false);
  }
</script>

<style>
</style>
